
use WebSecurity;
GO
-- Drop stored procedure if it already exists
IF EXISTS (
  SELECT * 
    FROM INFORMATION_SCHEMA.ROUTINES 
   WHERE SPECIFIC_CATALOG = N'WebSecurity' 
	 AND SPECIFIC_SCHEMA = N'dbo'
     AND SPECIFIC_NAME = N'UserProfile_GetOne' 
)
   DROP PROCEDURE dbo.UserProfile_GetOne
GO
create procedure dbo.UserProfile_GetOne
@UserId Int = null OUTPUT,
	@RowsAffected int = null OUTPUT 
	
--*************************************************************
--Created By: trooks
--Name: dbo_UserProfile_GetOne
--Table: UserProfile 
--Schema: dbo
--Database: WebSecurity
--Created Date: 01/21/2013 00:00:00
--*************************************************************

as
	Begin Try
		Select 
		UserId, 
		UserName, 
		TS, 
		CreatedBy, 
		CreatedDt, 
		ModifiedBy, 
		ModifiedDt, 
		IsActive, 
		FirstName, 
		LastName, 
		Address, 
		City, 
		Region, 
		PostalCode, 
		OfficePhone, 
		CellPhone, 
		Title 
		From [dbo].UserProfile
		 where
		 @UserId = UserId

		Set @RowsAffected = @@ROWCOUNT;
		return 0;	
	END TRY
	BEGIN CATCH
		Set @RowsAffected = 0;
		EXEC dbo.uspLogError;
		return -1;
	END CATCH
	
GO
GRANT EXECUTE ON [WebSecurity].[dbo].[UserProfile_GetOne] to PORTAL_WebSecurity
GO